﻿using Microsoft.AspNetCore.Mvc;
using MVC_System.DTO.GualityGroup;
using MVC_System.DTO.GualityProject;
using MVC_System.DTO.GualityScheme;
using WMS_MAV;

namespace MVC_System.Controllers
{
    public class GualitySchemeController : Controller
    {
        private readonly IConfiguration _configuration;
        public GualitySchemeController(IConfiguration configuration)
        {
            _configuration = configuration;
        }
        public IActionResult GualitySchemeList()
        {
            return View();
        }
        public async Task<ActionResult> GualitySchemeShow(GualitySchemeShowDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "HysSwagger/api/GualityScheme/GetGualityScheme?pageindex=" + dto.pageindex + "&pagesize=" + dto.pagesize + "&gualitySchemeNumbering=" + dto.gualitySchemeNumbering + "&state=" + dto.state;
            var respomse = await client.GetAsync(url);
            return Json(respomse);
        }
        public async Task<ActionResult> GualitySchemeDelete(GualitySchemeDeleteDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "HysSwagger/api/GualityScheme/DeleteGualityScheme";
            var respomse = await client.PostAsync(url, dto.Data);
            return Json(respomse);
        }
        public IActionResult GualitySchemeAdd()
        {
            return View();
        }
        public async Task<ActionResult> GualitySchemeAddShow(GualitySchemeAddDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "HysSwagger/api/GualityScheme/AddGualityScheme";
            var respomse = await client.PostAsync(url, dto.Data);
            return Json(respomse);
        }
        public IActionResult GualitySchemeUpdateView()
        {
            return View();
        }
        public async Task<ActionResult> GualitySchemeModel(GualitySchemeModelDTO dto)
        {
            HttpClientWrapper client = new HttpClientWrapper(dto.Token);
            string url = _configuration["Url"] + "HysSwagger/api/GualityScheme/ModelGualityScheme?gualitySchemeId=" + dto.gualitySchemeId;
            var respomse = await client.GetAsync(url);
            return Json(respomse);
        }
    }
}
